<?php
/* @var $this FuncionarioController */
/* @var $model Funcionario */
/* @var $form CActiveForm */
?>

<div class="form">

	<?php
	$form = $this->beginWidget('bootstrap.widgets.TbActiveForm', array(
			'id' => 'funcionario-form',
			// Please note: When you enable ajax validation, make sure the corresponding
			// controller action is handling ajax validation correctly.
			// There is a call to performAjaxValidation() commented in generated controller code.
			// See class documentation of CActiveForm for details on this.
			'enableAjaxValidation' => false,
	));
	?>

	<p class="note">
		Campos com <span class="required">*</span> são obrigatórios.
	</p>

	<?php echo $form->errorSummary($model); ?>
	<?php echo $form->errorSummary($pessoa); ?>
	<?php echo $form->errorSummary($usuario); ?>

	<?php echo $form->textFieldRow($pessoa,'nome',array('class'=>'span5','maxlength'=>250)); ?>
	<?php echo $form->textFieldRow($pessoa,'email',array('class'=>'span5','maxlength'=>250)); ?>

	<div class="row">

		<span style="float: left; width: 250px;"> <?php echo $form->labelEx($usuario, 'username'); ?>
			<?php echo $form->textField($usuario, 'username'); ?> <?php echo $form->error($usuario, 'username'); ?>
		</span> <span style="float: left; width: 250px;"> <?php echo $form->labelEx($usuario, 'password'); ?>
			<?php echo $form->passwordField($usuario, 'password'); ?> <?php echo $form->error($usuario, 'password'); ?>
		</span> <span style="float: left; width: 150px;"> <?php echo $form->labelEx($model, 'tipo'); ?>
			<?php
			echo $form->dropDownList($model, 'tipo', array('Administrador'=>'Administrador','Funcionario' => 'Funcionário',
					'Voluntario' => 'Voluntário'), array('empty' => ''));
			?> <?php echo $form->error($model, 'tipo'); ?>
		</span>
	</div>
	<div class="row">

		<span style="float: left; width: 250px;"> <?php
		$polos = Polo::model()->findAll();
		$polos_id = array();
		foreach ($polos as $polo) {
			$polos_id[$polo->id] = $polo->nome;
		}
		?> <?php echo $form->labelEx($model, 'polo_id'); ?> <?php
		echo $form->dropDownList($model, 'polo_id', $polos_id, array('empty' => ''));
		?> <?php echo $form->error($model, 'polo_id'); ?>
		</span> <span style="float: left; width: 250px;"> <?php echo $form->labelEx($pessoa, 'cpf'); ?>
			<?php
			$this->widget('CMaskedTextField', array(
					'model' => $pessoa,
					'attribute' => 'cpf',
					'name' => 'cpf_field',
					'mask' => '99999999999',
					'htmlOptions' => array(
							'style' => 'width:207px;'
					),
			));
			?> <?php echo $form->error($pessoa, 'cpf'); ?>
		</span> <span style="float: left; width: 150px;"> <?php echo $form->labelEx($pessoa, 'rg'); ?>
			<?php echo $form->textField($pessoa, 'rg', array('maxlength' => 10)); ?>
			<?php echo $form->error($pessoa, 'rg'); ?>
		</span>
	</div>

	<div class="row">
		<span style="float: left; width: 250px;"> <?php echo $form->labelEx($pessoa, 'data_de_nascimento'); ?>
			<?php
			$this->widget('zii.widgets.jui.CJuiDatePicker', array(
					'model' => $pessoa,
					'attribute' => 'data_de_nascimento',
					'name' => 'data_de_nascimento',
					'options'=>array(
							'type' => 'date',
							'dateFormat'=>'dd-mm-yy',
							'style' => 'width:207px',
							'showAnim'=>'slide',//'slide','fold','slideDown','fadeIn','blind','bounce','clip','drop'
							'changeMonth'=>true,
							'changeYear'=>true,
							'yearRange'=>'1900:2099',
							'minDate' => '01-01-1900',      // minimum date
							'maxDate' => '31-12-2099',
					),
			));
			?> <?php echo $form->error($pessoa, 'data_de_nascimento'); ?>
		</span> <span style="float: left; width: 250px;"> <?php echo $form->labelEx($pessoa, 'genero'); ?>
			<?php echo $form->dropDownList($pessoa, 'genero', array('Masculino' => 'Masculino', 'Feminino' => 'Feminino'), array('empty' => '')); ?>
			<?php echo $form->error($pessoa, 'genero'); ?>
		</span> <span style="float: left; width: 150px;"> <?php echo $form->labelEx($model, 'pis_pasep'); ?>
			<?php
			$this->widget('CMaskedTextField', array(
					'model' => $model,
					'attribute' => 'pis_pasep',
					'name' => 'pis_pasep',
					'mask' => '99999999999',
					'htmlOptions' => array(
							'style' => 'width:207px;'
					),
			));
			?> <?php echo $form->error($model, 'pis_pasep'); ?>
		</span>
	</div>
	<?php echo $form->textFieldRow($pessoa,'endereco',array('class'=>'span5','maxlength'=>250)); ?>
	<div class="row">

		<span style="float: left; width: 250px;"> <?php echo $form->labelEx($pessoa, 'naturalidade'); ?>
			<?php echo $form->textField($pessoa, 'naturalidade', array('size' => 60, 'maxlength' => 45)); ?>
			<?php echo $form->error($pessoa, 'naturalidade'); ?>
		</span> <span style="float: left; width: 250px;"> <?php echo $form->labelEx($pessoa, 'uf'); ?>
			<?php echo $form->textField($pessoa, 'uf'); ?> <?php echo $form->error($pessoa, 'uf'); ?>
		</span> <span style="float: left; width: 150px;"> <?php echo $form->labelEx($pessoa, 'cep'); ?>
			<?php
			$this->widget('CMaskedTextField', array(
					'model' => $pessoa,
					'attribute' => 'cep',
					'name' => 'cep',
					'mask' => '99999999',
					'htmlOptions' => array(
							'style' => 'width:207px;'
					),
			));
			?> <?php echo $form->error($pessoa, 'cep'); ?>
		</span>
	</div>

	<div class="row">
		<span style="float: left; width: 250px;"> <?php echo $form->labelEx($pessoa, 'telefone'); ?>
			<?php echo $form->textField($pessoa, 'telefone', array('size' => 20, 'maxlength' => 20)); ?>
			<?php echo $form->error($pessoa, 'telefone'); ?>
		</span> <span style="float: left; width: 250px;"> <?php echo $form->labelEx($pessoa, 'celular'); ?>
			<?php echo $form->textField($pessoa, 'celular', array('size' => 20, 'maxlength' => 20)); ?>
			<?php echo $form->error($pessoa, 'celular'); ?>
		</span> <span style="float: left; width: 150px;"> <?php 
		$turno_list = Caracteristica::model()->findAllByAttributes(array('tipo'=>'Horario'));
		$turnos = array();
		foreach ($turno_list as $turno) {
			$turnos[$turno->nome] = $turno->nome;
		}
		?> <?php echo $form->labelEx($model, 'horario')?> <?php echo $form->dropDownList($model, 'horario', $turnos, array('empty' => '')); ?>

			<?php echo $form->error($model, 'horario'); ?>
		</span>
	</div>
	<div class="row">
		<span style="float: left; width: 250px;"> <?php echo $form->labelEx($pessoa, 'escolaridade'); ?>
			<?php echo $form->dropDownList($pessoa, 'escolaridade', Pessoa::$escolaridades, array('empty' => '')); ?>
			<?php echo $form->error($pessoa, 'escolaridade'); ?>
		</span> <span style="float: left; width: 250px;"> <?php echo $form->labelEx($pessoa, 'rede_ensino'); ?>
			<?php echo $form->dropDownList($pessoa, 'rede_ensino', Pessoa::$redes_ensino, array('empty' => '')); ?>
			<?php echo $form->error($pessoa, 'rede_ensino'); ?>
		</span> <span style="float: left; width: 150px;"> <?php echo $form->labelEx($model, 'curso_formacao'); ?>
			<?php echo $form->textField($model, 'curso_formacao', array('size' => 60, 'maxlength' => 250)); ?>
			<?php echo $form->error($model, 'curso_formacao'); ?>
		</span>
	</div>
	<?php echo $form->textFieldRow($model,'instituicao_ensino',array('class'=>'span5','maxlength'=>250)); ?>

	<?php echo $form->textAreaRow($model, 'observacao'); ?>
	<br />
	<div align="center" class="form-actions">
		<?php $this->widget('bootstrap.widgets.TbButton', array(
				'buttonType'=>'submit',
				'type'=>'primary',
				'label'=>$model->isNewRecord ? 'Cadastrar' : 'Salvar',
		)); ?>
	</div>

	<?php $this->endWidget(); ?>

</div>
<!-- form -->
